import { createApp } from 'vue';
import App from './App.vue';
import '@purge-icons/generated';
import '@/design/index.scss';
import 'element-plus/es/components/message/style/css';
import 'element-plus/es/components/message-box/style/css';
import 'nprogress/nprogress.css';
import { setupPinia } from '@/store';
import { setupLocales } from '@/locales/setupI18n';
import { initStore } from '@/store/initStore';
import { setupRouter, router } from '@/router';
import { setupRouterGuard } from '@/router/guard';
import { MotionPlugin } from '@vueuse/motion';
import { setupDynamicForm } from '@/dynamicForm';
import { useDefHttp } from '@/api/useHttp';

const app = createApp(App);

const bootstrap = async () => {
  //挂载store
  setupPinia(app);

  //初始化store
  initStore();

  //挂载vue-i18n,
  await setupLocales(app);

  //挂载路由
  setupRouter(app);

  //挂载路由守卫
  setupRouterGuard(router);

  //挂载动态表单
  setupDynamicForm(app);

  //挂载动画插件
  app.use(MotionPlugin);

  app.mount('#app');
};

bootstrap();
